package com.hdax.dm.listener;

import com.hdax.dm.service.SchedulerSeatService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@RabbitListener(queues = "seat_rollback")
@Component
public class SeatMQListener {

    @Autowired
    private SchedulerSeatService seatService;

    @RabbitHandler
    public void rollBackSeat(Channel channel, Message message,String orderNo) throws Exception{
        seatService.rollBackSeat(orderNo);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
